package com.nkym.wypan.enums.share;

import lombok.Data;

import java.util.Arrays;

public enum ShareDayType {

    PERMANENT(0, 0, "永久有效"),
    SEVEN_DAYS(1, 7, "7天有效"),
    THIRTY_DAYS(2, 30, "30天有效");

    private Integer code;
    private Integer day;
    private String desc;

    ShareDayType(Integer code, Integer day, String desc) {
        this.code = code;
        this.day = day;
        this.desc = desc;
    }

    public static Integer getDaysForDayType(Integer typeCode) {
        ShareDayType[] types = values();
        for (ShareDayType type : types) {
            if (type.code.equals(typeCode)) {
                return type.day;
            }
        }
        return -1;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public Integer getDay() {
        return day;
    }

    public void setDay(Integer day) {
        this.day = day;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }
}
